package com.itheima.test.myanno;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class AnnoTest01 {//判断Test02中那些方法使用了注解
    public static void main(String[] args) throws IllegalAccessException, InstantiationException, InvocationTargetException {
        //获取字节码文件
        Class<AnnoTest02> annoTest02Class = AnnoTest02.class;
        //创建对象
        AnnoTest02 annoTest02 = annoTest02Class.newInstance();
        //获取Test02中方法
        Method[] methods = annoTest02Class.getDeclaredMethods();
        for (Method method : methods) {
            //判断是否使用了注解
            boolean result = method.isAnnotationPresent(Anno.class);
            if(result){
                method.invoke(annoTest02);
            }

        }
    }
}
